package cn.wolfcode.demo;


import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.runtime.ProcessInstance;
import org.junit.Test;

import java.util.HashMap;

public class demo3 {
    @Test
    public void testDemo(){
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        System.out.println(processEngine);
    }
    @Test
    public void testDeploy(){
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        RepositoryService repositoryService = processEngine.getRepositoryService();
        Deployment deployment = repositoryService.createDeployment().addClasspathResource("bpnm/leave-uel.bpmn")
                .addClasspathResource("bpnm/leave-uel.png")
                .name("员工请假批准").deploy();
        System.out.println(deployment.getId() + "流程部署ID");
        System.out.println("流程部署名称" + deployment.getName());
    }
    @Test
    public void testRun(){
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        RuntimeService runtimeService = processEngine.getRuntimeService();

        HashMap<String, Object> map = new HashMap<>();
        map.put("assignee0","zhangsan");
        map.put("assignee1","lisi");
        ProcessInstance instance = runtimeService.startProcessInstanceByKey("leave-uel",map);
        System.out.println("流程定义的id" + instance.getProcessDefinitionId());
        System.out.println("流程实例的id" + instance.getId());
    }

}
